/*
 *  txdnet.cn tonydon
 * 
 */
package cn.txdnet.txcms.view.action;

import cn.txdnet.txcms.domain.HotShop;
import cn.txdnet.txcms.service.HotShopService;
import cn.txdnet.txweb.annotation.methods.GetMethod;
import cn.txdnet.txweb.model.ModelUtil;
import cn.txdnet.txweb.model.ModelView;
import cn.txdnet.txweb.utils.Message;
import cn.txdnet.txweb.utils.WebUtil;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author txdnet
 */
public class HotShopAction {

    /**
     * 展示详情
     *
     * @param req
     * @return
     */
    public ModelView view(HttpServletRequest req) {
        String channelTemplate = WebUtil.getNoNull(req, "ct", "base");
        long shopid = WebUtil.getLong(req, "id", -1);
        if (shopid < 0) {
            return ModelUtil.getTextModel(Message.MSG_VALUE_NULL);
        }
        HotShop shop = HotShopService.queryShopForView(shopid);
        if (shop == null) {
            return ModelUtil.getTextModel(Message.MSG_VALUE_NULL);
        }
        return ModelUtil.getJspModel(channelTemplate.concat("_view"), shop);
    }

    /**
     * 信息浏览次数更新
     *
     * @param req
     * @return
     */
    @GetMethod
    public void hit_num(HttpServletRequest req) {
        long shopid = WebUtil.getLong(req, "id", -1);
        if (shopid < 0) {
            return;
        }
        HotShopService.increaseHitNum(shopid);
    }
}
